import React, { Component } from 'react'
import { connect } from 'react-redux'
import action from './store/actionCreator'
class App extends Component {
  componentDidMount () {
    this.props.getBannerList()
    this.props.getProList()
  }
  render() {
    const { bannerList, proList } = this.props
    return (
      <div>
        {
          bannerList.map(item => {
            return (
              <img key={ item.bannerid } src={item.img} alt=""/>
            )
          })
        }
        {
          proList.map(item => {
            return (
            <div key = { item.proid }> { item.proname }</div>
            )
          })
        }
      </div>
    )
  }
}

export default connect(
  (state) => {
    return {
      bannerList: state.bannerList,
      proList: state.proList
    }
  },
  (dispatch) => {
    return {
      getBannerList () {
        // 如果没有参数  不要加（）
        dispatch(action.getBannerListAction)
      },
      getProList () {
        // 有参数 必须加 （）
        dispatch(action.getProListAction({limitNum:30}))
      }
    }
  }
)(App)